<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div :style="{fontSize: font + 'px'}">{{ msg }}</div>
        <div-child :title="msg" @enlarge-text="enlarge"></div-child>
    </div>

    <script>
        Vue.component('div-child',{
            props: ['title'],
            data: function(){
                    return {
                        cmsg: '子组件的数据'
                    }
            },
            template: `
            <div>
                <div>{{ cmsg + "-----" + title }}</div>
                <button @click="$emit('enlarge-text')">增大字体大小</button>
            </div>
            `
        });
        var vm = new Vue({
            el: '#app',
            data: {
                msg: '父组件的数据',
                font: 10
            },
            methods: {
                enlarge: function(){
                    this.font += 4;
                }
            }
        })
    </script>
</body>
</html>